#!/usr/bin/env python
# -*- coding: utf-8
import socket

# 客户端
def client(host='192.168.31.219', port=10000):
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        # 连接服务端
        s.connect((host, port))
        print(f"已连接到服务端 {host}:{port}")

        while True:
            # 发送消息
            message = input("请输入消息: ")
            if message.lower() == 'exit':
                break
            s.sendall(message.encode('utf-8'))

            # 接收服务端回复
            data = s.recv(1024)
            print(f"服务端回复: {data.decode('utf-8')}")

if __name__ == "__main__":
    client()

